/**
 * 
 */
package trungsi.gea.photos.dao;

import javax.jdo.PersistenceManager;

import trungsi.gea.photos.jdo.PersistenceManagerHolder;

/**
 * @author trungsi
 *
 */
public class JdoTemplate {

	private PersistenceManagerHolder pmHolder;
	
	public void setPersistenceManagerHolder(PersistenceManagerHolder pmHolder) {
		this.pmHolder = pmHolder;
	}
	
	public <T> T execute(JdoCallback<T> jdoCallback) {
		return jdoCallback.doWithPersistenceManager(getCurrentPersistenceManager());
	}

	private PersistenceManager getCurrentPersistenceManager() {
		return pmHolder.get();
	}

}
